/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.aseo.model.entity;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Set;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.NotEmpty;

/**
 *
 * @author usuario
 */
@Entity
@Table(name = "supervision")
public class Supervision implements Serializable {
    private static final long serialVersionUID = 1L;
    @SequenceGenerator(name = "supervision_id_supervision_seq", sequenceName = "supervision_id_supervision_seq")
    @GeneratedValue(generator = "supervision_id_supervision_seq")
    @Id
    @Basic(optional = false)
    @Column(name = "id_supervision")
    private Long idSupervision;
    @Column(name = "fecha_hora")
    private Timestamp fechaHora;
    @NotNull (message="Debe especificar el reclamo al que se le realizo la supervision")
    @JoinColumn(name = "id_reclamo", referencedColumnName = "id_reclamo")
    @ManyToOne
    private Reclamo idReclamo;
    @NotNull (message="Debe especificar el supevisor")
    @JoinColumn(name = "id_supervisor", referencedColumnName = "id_supervisor")
    @ManyToOne
    private Supervisor idSupervisor;
    @NotEmpty(message = "Debe especificar las observaciones") 
    @Column(name = "observaciones")
    private String observaciones;
    @OneToMany( fetch=FetchType.EAGER, cascade = CascadeType.ALL, mappedBy = "idSupervision", targetEntity = SupervisionMedia.class)
    private Set<SupervisionMedia> supervisionMediaCollection;

    public Supervision() {
    }

    public Supervision(Long idSupervision) {
        this.idSupervision = idSupervision;
    }

    public Long getIdSupervision() {
        return idSupervision;
    }

    public void setIdSupervision(Long idSupervision) {
        this.idSupervision = idSupervision;
    }

    public Timestamp getFechaHora() {
        return fechaHora;
    }

    public void setFechaHora(Timestamp fechaHora) {
        this.fechaHora = fechaHora;
    }

    public String getObservaciones() {
        return observaciones;
    }

    public void setObservaciones(String observaciones) {
        this.observaciones = observaciones;
    }

    public Reclamo getIdReclamo() {
        return idReclamo;
    }

    public void setIdReclamo(Reclamo idReclamo) {
        this.idReclamo = idReclamo;
    }

    public Supervisor getIdSupervisor() {
        return idSupervisor;
    }

    public void setIdSupervisor(Supervisor idSupervisor) {
        this.idSupervisor = idSupervisor;
    }

    public Set<SupervisionMedia> getSupervisionMediaCollection() {
        return supervisionMediaCollection;
    }

    public void setSupervisionMediaCollection(Set<SupervisionMedia> supervisionMediaCollection) {
        this.supervisionMediaCollection = supervisionMediaCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idSupervision != null ? idSupervision.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Supervision)) {
            return false;
        }
        Supervision other = (Supervision) object;
        if ((this.idSupervision == null && other.idSupervision != null) || (this.idSupervision != null && !this.idSupervision.equals(other.idSupervision))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.aseo.model.entity.Supervision[idSupervision=" + idSupervision + "]";
    }

}
